<!--
  ~ This program is part of the OpenLMIS logistics management information system platform software.
  ~ Copyright © 2013 VillageReach
  ~
  ~ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  ~  
  ~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
  ~ You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
  -->

<div ng-controller="CreateRegimenLineItemController">
    <div class="rnr-table regimen-table" tab-scroll bottom-offset="180">
        <table id="regimenTable" fixed-table-header class="table table-bordered scrollable">
            <thead>
            <tr>
                <th class="col-{{regimenColumn.name}}" ng-repeat="regimenColumn in visibleRegimenColumns">
                    <div class="regimen-heading">

                        <span openlmis-message="regimenColumn.label"></span>
                        <span ng-if="regimenColumn.name == 'skipped'">
                            <a href="" id="selectAll" ng-click="setSkipAll(true)" openlmis-message="label.select.all"></a>&nbsp;|
                            <a href="" id="selectNone" ng-click="setSkipAll(false)" openlmis-message="label.select.none"></a>
                        </span>
                    </div>
                </th>
            </tr>
            </thead>
            <tbody ng-repeat="regimenLineItem in page.regimen">
            <tr>
                <td class="productCategory" colspan="{{visibleRegimenColumns.length}}" ng-show="showCategory($index)"
                    ng-bind="regimenLineItem.category.name"></td>
            </tr>
            <tr>
                <td class="cell-input col-{{ regimenColumn.name }}" ng-repeat="regimenColumn in visibleRegimenColumns">
                    <ng-switch on="regimenColumn.name">
              <span ng-switch-when="name">
                <span ng-bind="regimenLineItem.name" class="cell-text"></span>
              </span>
              <span ng-switch-when="code">
                <span ng-bind="regimenLineItem.code" class="cell-text"></span>
              </span>
               <span ng-switch-when="skipped">
                <input ng-model="regimenLineItem.skipped" type="checkbox" />
              </span>
              <span ng-switch-when="remarks">
                <input id="remarks_{{$parent.$parent.$index}}" type="text"
                       ng-model="regimenLineItem[regimenColumn.name]" class="cell-text"
                       ng-disabled="formDisabled || regimenLineItem.skipped" maxlength="255">
              </span>
              <span ng-switch-default class="input-error-parent-cell">
                <input ng-class="{'required-error': ( !regimenLineItem['skipped'] && (!regimenLineItem[regimenColumn.name] && regimenLineItem[regimenColumn.name] !== 0 && $parent.regimenLineItemInValid) )}"
                       id="{{getId(regimenColumn.name, $parent)}}"
                       name="{{regimenColumn.name + $parent.$parent.$index}}"
                       type="text" ng-model="regimenLineItem[regimenColumn.name]" ng-required="true" ng-trim="false"
                       numeric-validator="positiveInteger" maxlength="8" ng-disabled="formDisabled || regimenLineItem.skipped">
                <span class="rnr-form-error" id="{{regimenColumn.name + $parent.$parent.$index}}"
                      style="display:none;" openlmis-message="error.number.only">
              </span>
              </span>
                    </ng-switch>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>